﻿<UserControl
    x:Class="Org.AdamHill.Sl.Tools.PathCompressor.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Org.AdamHill.Sl.Tools.PathCompressor" 
    mc:Ignorable="d"
    d:DesignHeight="600" 
	d:DesignWidth="960"
	>
	<UserControl.Resources>
		<Style TargetType="TextBox"><!--implicit-->
			<Setter Property="FontFamily" Value="Consolas"/>			
			<Setter Property="IsReadOnly" Value="True"/>			
			<Setter Property="Foreground" Value="#FFA0A0A0"/>						
			<Setter Property="AcceptsReturn" Value="True"/>						
			<Setter Property="VerticalAlignment" Value="Stretch"/>						
			<Setter Property="HorizontalAlignment" Value="Stretch"/>						
		</Style>
		<Style x:Key="H1TextStyle" TargetType="TextBlock">
			<Setter Property="FontFamily" Value="Segoe UI"/>
			<Setter Property="FontSize" Value="32"/>			
		</Style>
		<Style x:Key="H2TextStyle" TargetType="TextBlock">
			<Setter Property="FontFamily" Value="Segoe UI"/>
			<Setter Property="FontSize" Value="18.667"/>			
		</Style>
		<Style x:Key="BodyTextStyle" TargetType="TextBlock">
			<Setter Property="FontFamily" Value="Calibri"/>
			<Setter Property="FontSize" Value="13"/>			
		</Style>	
		<Style x:Key="ButtonText1Style" TargetType="TextBlock">
			<Setter Property="FontFamily" Value="Calibri"/>
			<Setter Property="FontSize" Value="10"/>			
		</Style>	
		<Style x:Key="ButtonText2Style" TargetType="TextBlock">
			<Setter Property="FontFamily" Value="Calibri"/>
			<Setter Property="FontSize" Value="18"/>
			<Setter Property="FontWeight" Value="Bold"/>
		</Style>
		<SolidColorBrush x:Key="TextGreyBrush" Color="#FFA0A0A0"/>	
	</UserControl.Resources>
	<Viewbox x:Name="LayoutRoot" Margin="10" >
		<Grid x:Name="LayoutRootFixed" Background="White" Height="600" Width="960">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="*"/>
				<RowDefinition Height="Auto"/>			  	
			</Grid.RowDefinitions>
			<StackPanel Margin="10">
				<TextBlock Text="XAML/SVG Path Compressor" 
					HorizontalAlignment="Center" 
					Style="{StaticResource H1TextStyle}"/>
				<TextBlock Text="Instructions:" 
					Style="{StaticResource H2TextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
				<StackPanel Margin="10">
                    <TextBlock Text="1. Save / backup your data before using this tool." 
						Style="{StaticResource BodyTextStyle}"/>
                    <TextBlock Text="2. Copy your XAML/SVG Document or Path's Data string to the clipboard." 
						Style="{StaticResource BodyTextStyle}"/>
                    <TextBlock Text="3. Select # decimal places to round nodes to." 
						Style="{StaticResource BodyTextStyle}"/>
					<TextBlock Text="4. Click the relevant button. It reads the clipboard, processes it and puts the processed version back on the clipboard."
						Style="{StaticResource BodyTextStyle}"/>
					<TextBlock Text="5. Paste back into your editor. Visually check your paths to ensure the level of compression is acceptable."
						Style="{StaticResource BodyTextStyle}"/>
				</StackPanel>
			</StackPanel>
			<Grid Grid.Row="1" Margin="10">
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="*"/>
					<RowDefinition Height="Auto"/>			  	
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="*"/>			  	
				</Grid.ColumnDefinitions>		  			
				<TextBlock Text="Original:" 
					Grid.Row="0"
					Grid.Column="0"
					Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
				<TextBlock Text="Processed:" 
					Grid.Row="0"
					Grid.Column="2"
					Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
				<TextBox x:Name="SourcePath" 
					Grid.Row="1"
					Grid.Column="0"
					HorizontalScrollBarVisibility="Auto"
					VerticalScrollBarVisibility="Auto"
				 />				
				<TextBox x:Name="OutputPath"
					Grid.Row="1"
					Grid.Column="2"
					HorizontalScrollBarVisibility="Auto"
					VerticalScrollBarVisibility="Auto"
				/>
				<StackPanel Grid.RowSpan="3" Grid.Column="1">
					<Grid Margin="10">
						<Grid.RowDefinitions>
							<RowDefinition/>
							<RowDefinition/>
							<RowDefinition/>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition/>
							<ColumnDefinition/>						
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Row="0" 
							Grid.Column="0" 
							Grid.ColumnSpan="2" 
							Text="Decimal Places:" Foreground="{StaticResource TextGreyBrush}" Margin="0,0,0,10"/>
						<TextBlock x:Name="DecimalPlaceTextBlock" 
							Grid.Row="1" 
							Grid.Column="0" 
							Grid.RowSpan="2" 
							TextAlignment="Center"
							Text="0"
							Style="{StaticResource ButtonText2Style}"
							VerticalAlignment="Center"/>
						<Button Grid.Row="1" 
							Grid.Column="1"
							Content="+"
							Click="IncrementDecimalPlacesClick"/>
						<Button Grid.Row="2" 
							Grid.Column="1"
							Content="-"
							Click="DecrementDecimalPlacesClick"/>
					</Grid>
					<Grid Margin="10,0,10,10">
						<TextBlock Grid.Row="0" 
							Grid.Column="0" 
							Text="Process Clipboard:" VerticalAlignment="Top" Foreground="{StaticResource TextGreyBrush}"/>
						<Button Margin="1,26,1,74" Click="CompressXamlPathDocumentClick" d:LayoutOverrides="Height">
							<StackPanel>
								<TextBlock Text="COMPRESS" 
									Style="{StaticResource ButtonText1Style}" HorizontalAlignment="Center"/>
								<TextBlock Text="XAML/SVG Doc" 
									Style="{StaticResource ButtonText2Style}" HorizontalAlignment="Center"/>
								<TextBlock Text="Paths" 
									Style="{StaticResource ButtonText1Style}" HorizontalAlignment="Center"/>
							</StackPanel>
						</Button>
						<Button Margin="1,0" Click="CompressXamlPathDataClick" VerticalAlignment="Bottom">
							<StackPanel>
								<TextBlock Text="COMPRESS" 
									Style="{StaticResource ButtonText1Style}" HorizontalAlignment="Center"/>
								<TextBlock Text="Path Data" 
									Style="{StaticResource ButtonText2Style}" HorizontalAlignment="Center"/>
								<TextBlock Text="String" 
									Style="{StaticResource ButtonText1Style}" HorizontalAlignment="Center"/>
							</StackPanel>					
						</Button>
					</Grid>
				</StackPanel>
				<TextBlock x:Name="SourceChars" Text="" 
					Grid.Row="2"
					Grid.Column="0"
					Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
				<TextBlock x:Name="CompressionPercentage" Text="" 
					Grid.Row="2"
					Grid.Column="1"
					Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
				<TextBlock x:Name="OutputChars" Text="" 
					Grid.Row="2"
					Grid.Column="2"
					Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
			</Grid>
			<Grid Grid.Row="2" Margin="10">
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>	
				<local:Signature Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
				<HyperlinkButton  
					Grid.Row="0"
					Grid.Column="0"
					Content="www.AdamHill.org"
					NavigateUri="http://www.adamhill.org" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="10,10,30,0"
				/>
			</Grid>
			<StackPanel Margin="10,10,220,10" Grid.Row="2">
				<TextBlock Text="About:" 
					Style="{StaticResource H2TextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
				<StackPanel Margin="10">
					<TextBlock Text="This tool is designed to help you shrink path-heavy XAML &amp; SVG documents with a simple, lossy form of compression." 
						Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
					<TextBlock Text="The principle is that it rounds any numbers in a Path's Data string, giving a shorter string." 
						Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
					<TextBlock Text="As points at 100% zoom are rounded to a pixel this can give 50%+ compression on the path data strings with minimal corruption." 
						Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
					<TextBlock Text="Note: when pasting in an entire XAML/SVG document the compression amount will be lower, as only some of the document is path data."
						Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="By Adam Hill, 31st July, 2011. Source Code available at "
    						Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource TextGreyBrush}"/>
                        <HyperlinkButton Content="pathcompressor.codeplex.com" NavigateUri="http://pathcompressor.codeplex.com/" />
                    </StackPanel>
				</StackPanel>
			</StackPanel>
		</Grid>
	</Viewbox>
</UserControl>

